package svc

import (
	"github.com/zeromicro/go-zero/core/logx"
	"go-exp/pkg/orm"
	"go-exp/query"
	"go-exp/zero/rpc/user/internal/config"
)

type ServiceContext struct {
	Config config.Config
	DB     *orm.DB
}

func NewServiceContext(c config.Config) *ServiceContext {
	db := orm.MustNewMysql(&orm.Config{DSN: c.DB.DataSource})
	logx.Debugf("db config: %+v", db)
	query.SetDefault(db.DB)
	return &ServiceContext{
		Config: c,
		DB:     db,
	}
}
